package com.dycx.common.enums;

import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 学历枚举值
 * @date 2023/2/23
 */
@Getter
public enum EducationEnum {
    PRIMARY_SCHOOL(1, "小学"),
    MIDDLE_SCHOOL(2, "初中"),
    HIGH_SCHOOL(3, "高中"),
    POLYTECHNIC_SCHOOL(4, "中专/技校"),
    JUNIOR_COLLEGE(5, "大专"),
    UNDERGRADUATE_COURSE(6, "本科"),
    MASTER(7, "硕士"),
    DR(8, "博士");

    private final Integer code;
    private final String name;

    EducationEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public static String converter(Integer code) {
        String name = "";
        for (EducationEnum item : EducationEnum.values()) {
            if (item.code.equals(code)) {
                name = item.getName();
            }
        }
        return name;
    }

    /**
     * 转为数据
     *
     * @return 枚举对象数组
     */
    public static List<Map<String, Object>> getList() {
        List<Map<String, Object>> list = new ArrayList<>();
        for (EducationEnum item : EducationEnum.values()) {
            Map<String, Object> map = new HashMap<>();
            map.put("code", item.getCode());
            map.put("name", item.getName());
            list.add(map);
        }
        return list;
    }
}
